using System;
using System.Data;
using System.Linq;
using System.ComponentModel;
using System.Reflection;
using System.Collections.Generic;
using DataObject.Database;
using DataObject.Model;

public partial class PaymentBatchMapper
{
    #region ToSingle

    public static PaymentBatchDTO ToSingle(PaymentBatch entity)
    {
        if (entity == null)
        {
            return null;
        }
        return new PaymentBatchDTO
        {
            ModifiedBy = entity.ModifiedBy,
            ModifiedDate = entity.ModifiedDate,
            PaidAmount = entity.PaidAmount,
            PaidFee = entity.PaidFee,
            PaymentBatchID = entity.PaymentBatchID,
            PaymentDate = entity.PaymentDate,
        };
    }

    #endregion

    #region ToEntity

    public static PaymentBatch ToEntity(PaymentBatch entity, PaymentBatchDTO businessobject)
    {
        if (businessobject == null)
        {
            return null;
        }
        entity.ModifiedBy = businessobject.ModifiedBy;
        entity.ModifiedDate = businessobject.ModifiedDate;
        entity.PaidAmount = businessobject.PaidAmount;
        entity.PaidFee = businessobject.PaidFee;
        entity.PaymentBatchID = businessobject.PaymentBatchID;
        entity.PaymentDate = businessobject.PaymentDate;
        return entity;
    }

    #endregion

    #region ToBusinessObject

    public static PaymentBatchDTO ToBusinessObject(PaymentBatch entity)
    {
        if (entity == null)
        {
            return null;
        }
        return new PaymentBatchDTO
        {
            ModifiedBy = entity.ModifiedBy,
            ModifiedDate = entity.ModifiedDate,
            PaidAmount = entity.PaidAmount,
            PaidFee = entity.PaidFee,
            PaymentBatchID = entity.PaymentBatchID,
            PaymentDate = entity.PaymentDate
        };
    }

    #endregion

    #region ToBusinessObjectHasChildren

    public static PaymentBatchDTO ToBusinessObjectHasChildren(PaymentBatch entity, params Type[] types)
    {
        if (entity == null)
        {
            return null;
        }
        PaymentBatchDTO businessobject = new PaymentBatchDTO
        {
            ModifiedBy = entity.ModifiedBy,
            ModifiedDate = entity.ModifiedDate,
            PaidAmount = entity.PaidAmount,
            PaidFee = entity.PaidFee,
            PaymentBatchID = entity.PaymentBatchID,
            PaymentDate = entity.PaymentDate
        };
        if (types.Contains<Type>(typeof(PaymentBatchDetail)) || types.Length == 0)
        {
            businessobject.PaymentBatchDetailCollection = new List<PaymentBatchDetailDTO>();
            foreach (var item in entity.PaymentBatchDetails)
            {
                businessobject.PaymentBatchDetailCollection.Add(PaymentBatchDetailMapper.ToBusinessObject(item));
            }
        }
        if (types.Contains<Type>(typeof(ReservationPayment)) || types.Length == 0)
        {
            businessobject.ReservationPaymentCollection = new List<ReservationPaymentDTO>();
            foreach (var item in entity.ReservationPayments)
            {
                businessobject.ReservationPaymentCollection.Add(ReservationPaymentMapper.ToBusinessObject(item));
            }
        }
        return businessobject;
    }

    #endregion

}
